//
//  XJSeckillGoodsHeader.m
//  XinJiangMall
//
//  Created by Tzyang on 2018/4/10.
//  Copyright © 2018年 Tzyang. All rights reserved.
//

#import "XJSeckillGoodsHeader.h"

@interface XJSeckillGoodsHeader ()

@property (nonatomic ,strong) UIView * xjsg_line;
@property (nonatomic ,strong) UILabel * xjsg_tipsLab;
@property (nonatomic ,strong) UIButton * xjsg_moreBtn;

@end

@implementation XJSeckillGoodsHeader

- (UILabel *)xjsg_tipsLab{
    if (!_xjsg_tipsLab) {
        UILabel * xjsg_tipsLab = [UILabel new];
        self.xjsg_tipsLab = xjsg_tipsLab;
        [self addSubview:xjsg_tipsLab];
    }
    return _xjsg_tipsLab;
}

- (UIButton *)xjsg_moreBtn{
    if (!_xjsg_moreBtn) {
        UIButton * xjsg_moreBtn = [UIButton new];
        self.xjsg_moreBtn = xjsg_moreBtn;
        [self addSubview:xjsg_moreBtn];
    }
    return _xjsg_moreBtn;
}

- (UIView *)xjsg_line{
    if (!_xjsg_line) {
        UIView * xjsg_line = [UIView new];
        self.xjsg_line =xjsg_line;
        [self addSubview:xjsg_line];
    }
    return _xjsg_line;
}

- (instancetype)initWithFrame:(CGRect)frame{
    
    if (self= [super initWithFrame:frame]) {
        
        self.backgroundColor = WHITE_COLOR;
        
        self.xjsg_line.backgroundColor = XJCOLOR_RGB(221, 221, 221);
        self.xjsg_line.frame = CGRectMake(10, 10.5, KWidth-20, 0.5);
        self.xjsg_tipsLab.text = @"附近秒杀圈";
        self.xjsg_tipsLab.font = XJFONTSET_M(16);
        self.xjsg_tipsLab.textColor = XJCOLOR_RGB(17, 17, 17);
        CGFloat xjsg_tipsLabW = [UILabel labelWithLabel:self.xjsg_tipsLab getWidthWithTitle:self.xjsg_tipsLab.text font:self.xjsg_tipsLab.font];
        CGFloat xjsg_tipsLabH = [UILabel labelWithLabel:self.xjsg_tipsLab getHeightByWidth:xjsg_tipsLabW title:self.xjsg_tipsLab.text font:self.xjsg_tipsLab.font];
        self.xjsg_tipsLab.sd_layout
        .leftSpaceToView(self, ADAPTWidth(16))
        .topSpaceToView(self.xjsg_line, 20 )
        .widthIs(xjsg_tipsLabW)
        .heightIs(xjsg_tipsLabH);
        
        [self.xjsg_moreBtn buttonWithTitle:@"查看更多" titleFont:XJFONTSET_R(14) titleColor:XJCOLOR_RGB(157, 165, 168) imageType:ImageTypeImg imageName:@"direction_right_gray" withTarget:self action:@selector(xjsg_moreBtnClick) style:ImgTextBtnStyleRight margin:15];
        self.xjsg_moreBtn.sd_layout
        .rightSpaceToView(self, UI_IS_IPHONE5?ADAPTWidth(20):ADAPTWidth(12))
        .centerYEqualToView(self.xjsg_tipsLab)
        .widthIs(UI_IS_IPHONE5?ADAPTWidth(80):ADAPTWidth(70))
        .heightIs(ADAPTHeight(20));
        
    }
    return self;
}

- (void)xjsg_moreBtnClick{
    
    if (_delegate && [_delegate respondsToSelector:@selector(xjsg_moreBtnAction)]) {
        [_delegate xjsg_moreBtnAction];
    }
    XJLog(@"秒杀商品查看更多");
}

@end
